/*
 * messages.c
 *
 *  Created on: Jun 15, 2012
 *      Author: esl32
 */

#include "messages.h"

void set_position(SerialConn* conn, char motor, double newPos)
{
   unsigned char pkt[9];
   pkt[0] = motor;
   double *p = (double*)(pkt + 1);
   *p = newPos;
   int i;
   //for (i=0;i<8;i++)
   //{
   //   printf("a: %x\n", pkt[i+1]);
   //}
   double* t;
   t = (double*)(pkt+1);
   //printf("d: %f", *t);
   write_packet(conn->fd, pkt, 9);
   //printf("jojo\n");
}

void get_position(SerialConn* conn)
{
   unsigned char pkt[1];
   pkt[0] = GET_POSITION;
   write_packet(conn->fd, pkt, 1);
}

void reset(SerialConn* conn)
{
   unsigned char pkt[1];
   pkt[0] = RESET;
   write_packet(conn->fd, pkt, 1);
}
